package com.enjoylearning.content.api;

import com.enjoylearning.content.mapper.CourseTeacherMapper;
import com.enjoylearning.content.model.dto.AddCourseTeacherDto;
import com.enjoylearning.content.model.po.CourseTeacher;
import com.enjoylearning.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;
    @Autowired
    private CourseTeacherMapper courseTeacherMapper;

    @ApiOperation("查询教师")
    @GetMapping("/courseTeacher/list/{id}")
    public List<CourseTeacher> getCourseTeacher(@PathVariable Long id) {
        return courseTeacherService.getCourseTeacher(id);
    }

    @ApiOperation("新增教师")
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody AddCourseTeacherDto addCourseTeacherDto) {
        return courseTeacherService.addCourseTeacher(addCourseTeacherDto);
    }

    @ApiOperation("修改教师")
    @PutMapping("/courseTeacher")
    public CourseTeacher updateCourseTeacher(@RequestBody CourseTeacher courseTeacher) {
        return courseTeacherService.updateCourseTeacher(courseTeacher);
    }

    @ApiOperation("删除教师")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteCourseTeacher(@PathVariable Long courseId, @PathVariable Long id) {
        courseTeacherService.deleteCOurseTeacher(courseId,id);
    }
}
